package demo.dubb;

import demo.dubbo.api.TimeApi;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;

import java.util.Date;

/**
 * 消费端代码
 * 1 reference
 * 2 application
 */
public class Consumer {
    public static void main(String[] args) {
        ApplicationConfig applicationConfig = new ApplicationConfig();
        applicationConfig.setName("test_Consumer");

        ReferenceConfig<TimeApi> referenceConfig = new ReferenceConfig<TimeApi>();
        referenceConfig.setApplication(applicationConfig);
        referenceConfig.setInterface(TimeApi.class);
        referenceConfig.setUrl("dubbo://192.168.15.1:20880/demo.dubbo.api.TimeApi");

        TimeApi timeApi = referenceConfig.get();
        Date date = timeApi.printTime();

        System.out.println("消费端获取时间:"+date);
    }
}
